package cn.mw.cmdb.param.zabbixResult;

import cn.mw.microMonitorCommon.util.DateUtils;
import com.google.common.base.Strings;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

import static cn.mw.cmdb.util.ValConvertUtil.longValueConvert;

/**
 * @description zabbix监控项最新数据
 */
@Data
@Schema(name = "zabbix趋势数据实体", description = "zabbix趋势数据实体")
public class ItemTrendResultParam implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "监控项ID")
    private String itemid;

    @Schema(description = "数据产生时间 单位：秒")
    private String clock;

    @Schema(description = "每小时产生的值数量")
    private String num;

    @Schema(description = "每小时最大值")
    private String value_max;

    @Schema(description = "每小时平均值")
    private String value_avg;

    @Schema(description = "每小时最小值")
    private String value_min;

    public String getDateConvert() {
        String formatDateTime = "";
        if (!Strings.isNullOrEmpty(clock)) {
            formatDateTime = DateUtils.formatDateTime(new Date(longValueConvert(clock) * 1000));
        }
        return formatDateTime;
    }
}
